import { request } from "@/utils/http";
import {
  Departments,
  DoctorItems,
  ProvinceItems,
  ReqGetDoctorsParams,
  ReqGetHospitalListParams,
  ReqGetHospitalListResponse,
  ReqGetHospitalScheduleRulesParams,
  ReqGetHospitalScheduleRulesResponse,
  ReqGetHospitalShowResponse,
} from "./model/hospitalListTypes";

/**
 * 获取省份信息
 * @returns Promise<ProvinceItems>
 */
export function reqGetProvince() {
  return request.get<any, ProvinceItems>(
    "/admin/cmn/dict/findByDictCode/province"
  );
}

/**
 *
 * @param parentId 对应区域的 id 信息
 * @returns Promise<ProvinceItems>
 */
export function reqGetCityOrDistrict(parentId: number) {
  return request.get<any, ProvinceItems>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  );
}

/**
 * 获取所有的医院类型数据
 * @returns Promise<ProvinceItems>
 */
export function reqGetHosType() {
  return request.get<any, ProvinceItems>(
    "/admin/cmn/dict/findByDictCode/Hostype"
  );
}

/**
 * 获取医院的列表内容
 * @param param0 请求参数
 * @returns Promise<ReqGetHospitalListResponse>
 */
export function reqGetHospital({
  page,
  limit,
  ...args
}: ReqGetHospitalListParams) {
  return request.get<any, ReqGetHospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: args,
    }
  );
}

/**
 * 获取医院的详情内容
 * @param id 医院的 id 编号
 * @returns Promise<ReqGetHospitalShowResponse>
 */
export function reqGetHospitalShow(id: string) {
  return request.get<any, ReqGetHospitalShowResponse>(
    `/admin/hosp/hospital/show/${id}`
  );
}

/**
 * 获取某个医院所有的科室
 * @param hoscode 医院的编号
 * @returns Promise<Departments>
 */
export function reqGetHospitalDeparment(hoscode: string) {
  return request.get<any, Departments>(`/admin/hosp/department/${hoscode}`);
}

/**
 *
 * @param param 请求所需的参数对象
 * @returns Promise<ReqGetHospitalScheduleRulesResponse>
 */
export function reqGetHospitalScheduleRule({
  page,
  limit,
  hoscode,
  depcode,
}: ReqGetHospitalScheduleRulesParams) {
  return request.get<any, ReqGetHospitalScheduleRulesResponse>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
}

/**
 * 获取某天排班的医生
 * @param param0 请求获取医生排班的对象
 * @returns Promise<DoctorItems>
 */
export function reqGetDoctors({ hoscode, depcode, workDate }: ReqGetDoctorsParams) {
  return request.get<any, DoctorItems>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
}

/**
 * 
 * @param hoscode 医院的编号
 * @param status  医院的状态
 * @returns Promise<null>
 */
export function reqUpdateHospitalStatus(hoscode: string, status: number){
  return request.get<any, null>(`/admin/hosp/hospital/updateStatus/${hoscode}/${status}`);
}